/**
 * json配置举例，更多配置请看 IConfigSchema
 * @author luguoxiang
 * @date 2022/7/5
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema } from '@/soar';
import { basePath } from './api';
import { MenuComponent } from '@/types/interface';
// 获取全部图标的列表

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'id',
    label: '数据库编码',
    dataType: 'string',
    form: {
      rules: true,
      disabled({ isUpdate }) {
        return isUpdate;
      },
    },
  },
  {
    field: 'name',
    label: '名称',
    dataType: 'string',
    form: {
      rules: true,
    },
  },
  {
    field: 'type',
    label: '数据源类名',
    dataType: 'string',
    form: {
      rules: true,
    },
  },
  {
    field: 'url',
    label: '数据源路径',
    dataType: 'string',
    form: {
      rules: true,
      component: 't-textarea',
      componentProps: {
        autosize: { rows: 4 },
      },
    },
  },
  {
    field: 'username',
    label: '数据源用户名',
    dataType: 'string',
    table: false,
    search: false,
    form: {
      rules: true,
    },
  },
  {
    field: 'password',
    label: '数据源密码',
    dataType: 'string',
    table: false,
    search: false,
    detail: false,
    form: {
      slots: 'password',
      rules: true,
    },
  },
  {
    field: 'driverClassName',
    label: '驱动类名',
    dataType: 'string',
    form: {
      componentProps: {
        placeholder: 'com.mysql.jdbc.Driver',
      },
    },
  },
  {
    field: 'disabled',
    label: '是否禁用',
    dataType: 'boolean',
    table: {
      slots: 'disabled',
    },
  },
];

export default fieldList;

/**
 * 组件配置（用于生成菜单数据）
 */
export const COMPONENTS: MenuComponent[] = [
  {
    title: '数据源管理',
    component: () => import('./List.vue'),
    sort: 70,
    keepalive: true,
    icon: 'server',
    permits: [`GET${basePath}/query`],
    elements: [
      { title: '新增', code: 'create', permits: [`POST${basePath}/create`] },
      { title: '更新', code: 'update', permits: [`POST${basePath}/update`, `GET${basePath}/detail`] },
      { title: '删除', code: 'remove', permits: [`POST${basePath}/remove`] },
      { title: '详情', code: 'detail', permits: [`GET${basePath}/detail`] },
      { title: '导入', code: 'import', permits: [`POST${basePath}/import`] },
      { title: '导出', code: 'export', permits: [`GET${basePath}/export`] },
    ],
  },
];
